package com.imooc.miaosha.config;

import com.imooc.miaosha.Message.MiaoshaMessage;
import com.imooc.miaosha.Message.OrderStatusMessage;
import com.imooc.miaosha.common.Const;
import com.imooc.miaosha.util.JsonData;
import com.imooc.miaosha.util.JsonUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MqSender<T>  {
    @Autowired
    AmqpTemplate amqpTemplate;
    public  void sendMiaoSha(MiaoshaMessage miaoshaMessage){
        amqpTemplate.convertAndSend(RabbitMqConfig.ORDER_EXCHANGE,"order.miaoshaorder", JsonUtil.Obj2String(miaoshaMessage));
    }
    public void  sendOrderStatus(OrderStatusMessage orderStatusMessage){
        amqpTemplate.convertAndSend(RabbitMqConfig.ORDER_STATUS_EXCHANGE_NAME,"orderStaus.order",JsonUtil.Obj2String(orderStatusMessage));
    }
}
